package 图形界面设计;

import java.util.Random;

public class text {
    public static void main(String[] args) {
        int[] arr0 ={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
        Random r = new Random();
        int[][] arr = new int[4][4];
        int temp = 0;//临时存储数据
        //打乱一维数组
        for (int i = 0; i < arr0.length; i++) {
            int count = r.nextInt(arr0.length);//表示数组的索引
            temp = arr0[i];
            arr0[i] = arr0[count];
            arr0[count] = temp;
        }

        for (int i = 0; i < arr0.length; i++) {
            System.out.print(arr0[i]+" ");
        }

        int count = 0;
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                arr[i][j] = arr0[count];
                count++;
            }
        }
        System.out.println("\n"+"上面是一维数组");
        //将一维数组赋值给二维数组
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                System.out.print(arr[i][j]+" ");
            }
            System.out.println();
        }

    }
}
